import { createRouter, createWebHistory } from 'vue-router';
import Login from '../views/Login.vue'
import Home from '../views/Home.vue'
import Cart from '../views/cart.vue'
import Category from '../views/category.vue'
import User from '../views/user.vue'
import ProductList from '../views/ProductList.vue'
import ProductDetail from '../views/ProductDetail.vue'
import CreateOrder from '../views/CreateOrder.vue'
import Order from '../views/Order.vue'
import OrderDetail from '../views/OrderDetail.vue'
import Address from '../views/Address.vue'
import AddressEdit from '../views/AddressEdit.vue'
import Setting from '../views/Setting.vue'

const routes = [
  {
    path: '/',
    redirect: 'Home'
  },
  {
    path: '/home',
    name: 'Home',
    component: Home, // 首页
    meta: {
      index: 1
    }
  },
  {
    path: '/login',
    name: 'Login',
    component: Login, // 登录页面
    meta: {
      index: 1
    }
  },
  {
    path: '/cart',
    name: 'Cart',
    component: Cart, // 购物车页面
    meta: {
      index: 1
    }
  },
  {
    path: '/category',
    name: 'Category',
    component: Category, // 分类页面
    meta: {
      index: 1
    }
  },
  {
    path: '/user',
    name: 'User',
    component: User, // 用户页面
    meta: {
      index: 1
    }
  },
  {
    path: '/product-list',
    name: 'product-list',
    component: ProductList, // 商品列表页面
    meta: {
      index: 2
    }
  },
  {
    path: '/product/:id',
    name: 'product',
    component: ProductDetail,// 商品详情页面
    meta: {
      index: 3
    }
  },
  {
    path: '/Create-order',
    name: 'Create-order',
    component: CreateOrder, // 订单生成页面
    meta: {
      index: 2
    }
  },
  {
    path: '/Order',
    name: 'Order',
    component: Order, // 我的订单
    meta: {
      index: 2
    }
  },
  {
    path: '/Order-detail',
    name: 'Order-detail',
    component: OrderDetail, // 订单详情
    meta: {
      index: 3
    }
  },
  {
    path: '/address',
    name: 'address',
    component: Address, // 地址管理
    meta: {
      index: 2
    }
  },
  {
    path: '/address-edit',
    name: 'address-edit',
    component: AddressEdit, // 编辑地址
    meta: {
      index: 3
    }
  },
  {
    path: '/setting',
    name: 'setting',
    component: Setting, // 编辑地址
    meta: {
      index: 2
    }
  },
  
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
